Skip to content

feat(cf-workers): add CORS utility and auto-decode request paths#37

Merged
alukach merged 1 commit into
refactor/simplify-cf-workersfrom
feat/transport-layer-config
May 21, 2026
Merged

feat(cf-workers): add CORS utility and auto-decode request paths#37
alukach merged 1 commit into
refactor/simplify-cf-workersfrom
feat/transport-layer-config

Conversation

@alukach
Copy link
Copy Markdown
Member

@alukach alukach commented Apr 16, 2026

Summary

  • add_cors_headers() sets permissive CORS headers for browser-accessible S3 proxies
  • RequestParts::from_web_sys() now percent-decodes the URL path automatically
  • Both eliminate common boilerplate patterns in consumer apps

Test plan

  • cargo check --target wasm32-unknown-unknown -p multistore-cf-workers passes
  • All native workspace tests pass

🤖 Generated with Claude Code

- add_cors_headers() sets permissive CORS headers for browser-accessible
  S3-compatible read-only proxies
- RequestParts::from_web_sys() now percent-decodes the URL path
  automatically

These eliminate two common boilerplate patterns in consumer apps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the feat label Apr 16, 2026
@alukach alukach merged commit 61eb37a into refactor/simplify-cf-workers May 21, 2026
8 of 12 checks passed
@alukach alukach deleted the feat/transport-layer-config branch May 21, 2026 05:04
alukach added a commit that referenced this pull request May 21, 2026
* feat(cf-workers): add RequestParts for ergonomic request extraction

Introduces RequestParts struct that extracts owned HTTP metadata from a
web_sys::Request and provides as_request_info() to borrow it for gateway
dispatch. Eliminates 8 lines of manual parsing boilerplate per handler.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor(cf-workers): trim public exports to essential API surface

Reduce public exports from 8 to 2 (response_from_gateway, headermap_from_js).
Remove dead code (xml_response, s3_error_response) and make internal helpers
pub(crate).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor(cf-workers): add WsHeaders newtype for ergonomic header conversion

Introduces WsHeaders wrapper around web_sys::Headers with From<&HeaderMap>,
working around orphan rule constraints. Replaces 4 manual header conversion
blocks in backend.rs and response.rs, and removes the now-unused headers_to_js.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor(cf-workers): encapsulate JsBody with private field and accessor methods

Makes JsBody's inner Option<ReadableStream> private to prevent accidental
mutation. Adds JsBody::new() constructor and stream() accessor.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor(cf-workers): replace response_from_gateway with GatewayResponseExt trait

Replaces the free function with an extension trait on GatewayResponse,
enabling method syntax: `result.into_web_sys()`. Improves discoverability
via IDE autocomplete on the GatewayResponse type.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* docs: update crate-layout to reflect cf-workers ergonomic improvements

Documents RequestParts, GatewayResponseExt, JsBody, and WsHeaders in the
cf-workers crate description.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: add .worktrees to gitignore

* refactor: make Body an associated type on ProxyBackend (#38)

Replaces the generic Body parameter on forward() with an associated
type, eliminating runtime downcasts via Box<dyn Any>. Body type
mismatches are now caught at compile time.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat(cf-workers): add CORS utility and auto-decode request paths (#37)

- add_cors_headers() sets permissive CORS headers for browser-accessible
  S3-compatible read-only proxies
- RequestParts::from_web_sys() now percent-decodes the URL path
  automatically

These eliminate two common boilerplate patterns in consumer apps.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add HandlerAction::response_headers_mut() for ergonomic header injection (#36)

Middleware that adds response headers (CORS, Server-Timing, etc.) no
longer needs to match on all three HandlerAction variants manually.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* refactor: use MaybeSend/MaybeSync on BucketRegistry and CredentialRegistry (#35)

This allows WASM implementations to use !Send types (like worker::Fetch
and the CF Cache API) directly, eliminating the need for spawn_local +
oneshot channel bridges.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: merge fix

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant